package com.rk.cust.domain.entity;

import com.rk.cust.common.exception.CustException;
import com.rk.cust.common.exception.ErrorCode;
import com.rk.cust.domain.vo.CertType;
import com.rk.cust.domain.vo.CustStatus;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

import java.util.Date;

@Slf4j
@Setter
@Getter
public class Cust {
    private Long id;

    private String corporation;

    private CertType certType;

    private String certNo;

    private CustStatus status;

    private Date createTime;

    private Date lastUpdateTime;

    public void activate(){
        switch (status){
            case delete:
                throw new CustException(ErrorCode.ACTIVATE_WHEN_STATUS_DELETE);
            case active:
                throw new CustException(ErrorCode.ACTIVATE_WHEN_STATUS_ACTIVE);
            case unactivated:
                status = CustStatus.active;
                break;
            default:
                throw new CustException(ErrorCode.ACTIVATE_WHEN_STATUS_UNKOWN);
        }
    }
}
